package com.ruoyi.project.jxy.controller;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.jxy.domain.Corpus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 语料,保存有每个技能对应的语料.Controller
 *
 * @author ruoyi
 * @date 2019-12-06
 */
@RestController
@RequestMapping("/jxy/atlas")
public class AtlasController extends BaseController {


    /**
     * 获取图谱意图列表
     */
    @PreAuthorize("@ss.hasPermi('jxy:atlas:getIntent')")
    @GetMapping("/getIntent")
    public AjaxResult getIntent() {
        Map paraMap = new HashMap();
        String result = HttpUtil.post("http://192.168.2.239:5000/get_intent", paraMap);
        return AjaxResult.success("获取成功", result);
    }

    /**
     * 图谱测试
     */
    @PreAuthorize("@ss.hasPermi('jxy:atlas:atlasTest')")
    @GetMapping("/atlasTest")
    public AjaxResult atlasTest(@RequestParam String intentType, @RequestParam String keywords) {
        Map paraMap = new HashMap();
        paraMap.put("intent", intentType);
        paraMap.put("keywords", keywords);
        String str = HttpUtil.post("http://192.168.2.239:5000/register",paraMap);
        return AjaxResult.success("获取成功", str);
    }
}
